﻿<!DOCTYPE html>
<html>

<head>
  <title>showuser</title>
  <meta http-equiv="X-UA-Compatible" content="IE=edge" />
  <meta http-equiv="content-type" content="text/html; charset=utf-8" />
  <meta name="apple-mobile-web-app-capable" content="yes" />
  <link href="resources/css/jquery-ui-themes.css" type="text/css" rel="stylesheet" />
  <link href="resources/css/axure_rp_page.css" type="text/css" rel="stylesheet" />
  <link href="data/styles.css" type="text/css" rel="stylesheet" />
  <link href="files/showuser/styles.css" type="text/css" rel="stylesheet" />
  <script src="resources/scripts/jquery-1.7.1.min.js"></script>
  <script src="resources/scripts/jquery-ui-1.8.10.custom.min.js"></script>
  <script src="resources/scripts/prototypePre.js"></script>
  <script src="data/document.js"></script>
  <script src="resources/scripts/prototypePost.js"></script>
  <script src="files/showuser/data.js"></script>
  <link rel="stylesheet" type="text/css" href="./css/themes/default/easyui.css">
  <link rel="stylesheet" type="text/css" href="./css/themes/icon.css">
  <link rel="stylesheet" type="text/css" href="./css/component.css" />
  <script src="./js/jquery.min.js" type="text/javascript"></script>
  <script src="./js/jquery.easyui.min.js"></script>
  <script type="text/javascript">
    $axure.utils.getTransparentGifPath = function () { return 'resources/images/transparent.gif'; };
    $axure.utils.getOtherPath = function () { return 'resources/Other.html'; };
    $axure.utils.getReloadPath = function () { return 'resources/reload.html'; };
  </script>
</head>

<body>
  <!-- 页面div元素显示位置设置 -->
  <div id="base" class="" style="text-align:center;position:absolute;margin:30px;">



    <table id="dg" class="easyui-datagrid" title="查看用户" style="width:1082px;height:auto;" data-options="singleSelect:true,collapsible:false,url:'/BackstageUser/showUser',method:'get',pagination:true,rownumbers: false,iconCls:'icon-edit',toolbar:'#tb',onClickRow: onClickRow">
      <thead>
        <tr>
          <!-- ,editor:{type:'datebox',options:{formatter:ww4,parser:w4}} -->
          <th data-options="field:'userId',width:80">用户编号</th>
          <th data-options="field:'userName',width:80,editor:'text'">用户名</th>
          <th data-options="field:'relName',width:80,editor:'text'">真实姓名</th>
          <th data-options="field:'userBirthday',width:100">出生日期</th>
          <th data-options="field:'userSex',width:80,editor:'text'">用户性别</th>
          <th data-options="field:'userPass',width:80">用户密码</th>
          <th data-options="field:'userTelphone',width:100,editor:'text'">用户手机号</th>
          <th data-options="field:'userEmile',width:100,editor:'text'">用户邮箱</th>
          <th data-options="field:'userAdress',width:100,editor:'text'">用户地址</th>
          <th data-options="field:'userState',width:80">用户状态</th>
          <th data-options="field:'userProblemNo',width:100,editor:'text'">用户密保问题</th>
          <th data-options="field:'userAnswer',width:100 ,editor:'text'">用户答案</th>
          <!-- <th data-options="field:'status',width:60,align:'center',editor:{type:'checkbox',options:{on:'P',off:''}}">Status</th> -->
        </tr>
      </thead>
    </table>
    <div id="tb" style="height:auto">
      <a href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'icon-save',plain:true" onclick="accept()">保存</a>
      <!-- <a href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'icon-remove',plain:true" onclick="removeit()">删除</a> -->
    </div>
    <script type="text/javascript">
      function formatter1(value, row,index){
        if (row.userState == 0) { 
         return "未通过"; 
        } else if (row.userState == 1) {
          return "已通过";
        } else if (row.userState == 2) { 
          return "已冻结"; 
        } 
      }
      var editIndex = undefined;
      function endEditing() {
        if (editIndex == undefined) { return true }
        if ($('#dg').datagrid('validateRow', editIndex)) {
          $('#dg').datagrid('endEdit', editIndex);
          editIndex = undefined;
          return true;
        } else {
          return false;
        }
      }
      function onClickRow(index) {
        if (editIndex != index) {
          if (endEditing()) {
            $('#dg').datagrid('selectRow', index)
              .datagrid('beginEdit', index);
            editIndex = index;
          } else {
            $('#dg').datagrid('selectRow', editIndex);
          }
        }
      }
      // function removeit(){//删除元素
      //   var row = $('#dg').datagrid('getSelected');
      //   if (row){
      //     $.post('/deleteorder',{orderid:row.orderid},function (d){
      //       if(1 == d.affectedRows){
      //         alert("删除成功！！！");
      //       }else{
      //         alert('删除失败，请重试');
      //       }
      //     })
      //   }
      //   if (editIndex == undefined){return}
      //   $('#dg').datagrid('cancelEdit', editIndex)
      //       .datagrid('deleteRow', editIndex);
      //   editIndex = undefined;
      // }
      function accept() {
        var row = $('#dg').datagrid('getSelected');
        if (endEditing()) {
          $('#dg').datagrid('acceptChanges');
        }
        if (row) {
          console.log("进来饿了");
          $.post('/BackstageUser/updateuser', { userId: row.userId, userName: row.userName, relName: row.relName, userPass: row.userPass, userSex: row.userSex, userTelephone: row.userTelephone, userEmile: row.userEmile, userProblemNo: row.userProblemNo, userAnswer: row.userAnswer }, function (d) {
            if (1 == d.affectedRows) {
              alert("保存成功！！！");
            } else {
              alert('保存失败，请重试');
            }
          })
        }
      }
      function ww4(date) {
        var y = date.getFullYear();
        var m = date.getMonth() + 1;
        var d = date.getDate();
        // var h = date.getHours();  
        return y + '-' + (m < 10 ? ('0' + m) : m) + '-' + (d < 10 ? ('0' + d) : d);

      }
      function w4(s) {
        var reg = '-'; //利用正则表达式分隔  
        var ss = (s.split(reg));
        var y = parseInt(ss[0], 10);
        var m = parseInt(ss[1], 10);
        var d = parseInt(ss[2], 10);
        // var h = parseInt(ss[3],10);  
        if (!isNaN(y) && !isNaN(m) && !isNaN(d)) {
          return new Date(y, m - 1, d);
        } else {
          return new Date();
        }
      }  
    </script>
  </div>
</body>

</html>